package com.smart.admin.controller;

import com.smart.admin.utils.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @Author xiaoqiang
 * @Version ControllerAdvice.java, v 0.1 2025年03月28日 14:43 xiaoqiang
 * @Description: TODO
 */
@ControllerAdvice
public class ConfigControllerAdvice {

    private static final Logger logger = LoggerFactory.getLogger(ConfigControllerAdvice.class);

    @ExceptionHandler(value = Exception.class)
    public Result<Object> handleException(Exception ex) {
        String errMsg = ex.getMessage();
        if (errMsg == null) {
            errMsg = "unknown exception ,pleas linked admin";
        }
        logger.error("[ConfigControllerAdvice#handleException] handleException error,message={}", errMsg,ex);
        return Result.fail("100",errMsg);
    }

}
